<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>新增一个三级分销比率</title>
		<script src="js/lib/jquery-1.11.0.js"></script>
		<link rel="stylesheet" href="css/lib/bootstrap.min.css"/>
		<link rel="stylesheet" href="css/lib/loading.css" />
		<script src="js/lib/bootstrap.min.js"></script>
		<script src="js/lib/loading.js"></script>
		<script src="js/base.js" type="text/javascript" charset="utf-8"></script>
		<!--<script src="js/lib/angular.min.js"></script>-->
	</head>
	<style>
		body{
			font-size:12px;
		}		
		table,
		th,
		td {
			border: 1px solid grey;
			border-collapse: collapse;
			padding: 5px;
			vertical-align: middle !important;
		}		
		table td:nth-child(odd) {
			background-color: #f1f1f1;
			
		}
		table td:nth-child(even) {
			
		}
		table tr:nth-child(even) {
			background-color:#ffffff;
		}
	</style>
	<body ng-app="myApp" ng-controller="customersCtrl">		
		<div class="">
		<!--加载动画-->
		<div class="wrapper">
            <div id="loader-wrapper">
                <div id="loader"></div>
            </div>
        </div>
			<div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
			<table class="table table-hover">				
				<tbody>
					<tr>
						<th colspan="12">设置三级分销产品返佣比率：</th>
					</tr>
					<tr>
						<td>品牌:</td>
						<td colspan="12">
					<!--<input  placeholder="请输入品牌ID"/>-->					
						<select name="" id="msg0" type="text" class="form-control" style="width:280px;">
							<option value="1">赚道钱包</option>
						</select>
						</td>											
					</tr>
					<tr>
						<td>选择返佣级别:</td>
						<td colspan="12">
							<select id="msg2" class="form-control" style="width:280px;" >
								<option value="">请选择</option>
								<option value="1">分销商</option>
								<option value="2">代理商</option>
								<option value="3">服务商</option>
							</select>
						</td>

					</tr>
					<tr>
						<td>设置返佣比率:</td>
						<td colspan="12">
							<input id="msg1" placeholder="例如：0.2为返佣20%最大不超过0.3" class="form-control" type="text" style="width:280px;"/>
						</td>
					</tr>
					<tr>
						<td colspan="12">
							<input id="btn" type="btn" value="新增" class="btn btn-danger"/>
						</td>
					</tr>					
				</tbody>
			</table>					
			</div>
			</div>
		</div>
	</body>
	<script>
	$(function(){
        $('#msg1').on('keyup',function(){
            var v = $("#msg1").val();
            if(v > 0.3){
                $('#msg1').val(0.3);
            }
        });
		$('#btn').click(function(){
			var msg0 = $('#msg0').val();
			var msg1 = $('#msg1').val();
			var msg2 = $('#msg2').val();
			if(msg1>=0.3){
				alert("输入有误")
			}
			
			if(msg0==""|| msg1==""|| msg2==""){
				alert('请确认输入信息')
			}else{
					$.ajax({
					type:"POST",
					url:window.baseUrl+"user/thirdlevel/ratio/add",
					async:true,
					dataType:"json",
					data:{
						brand_id:msg0,
						ratio:msg1,
						pre_level:msg2
					},
					success:function(data){
						alert('成功')
						console.log(data)
						$('#msg0').val()
						$('#msg1').val()
						$('#msg2').val()					
					},
					error:function(data){
						alert('失败')
					}
				});
			}
			
		
		})
	});
</script>
</html>

